﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NHibernate;
using NHibernate.Linq;
using Entities;
using RepositoriesInterfaces;

namespace Repositories
{
    public class TeacherRepository : BaseRepository<Teacher>, ITeacherRepository
    {
        public TeacherRepository(ISession session)
        {
            this._session = session;
        }
        
        public IList<Teacher> GetByDepartmentId(int departmentId)
        {
            _session.BeginTransaction();

            IList<Teacher> teachersList = (from s in _session.Query<Teacher>()
                                           where s.Department.Id == departmentId
                                           select s).Distinct().ToList();

            _session.Transaction.Commit();

            return teachersList;
        }
    }
}